<?php
require './user.php';
require './function.php';
//require './form.class.php';
if(is_file($path=_decode($_GET['path']))==false) {
header('Content-Type: text/html; charset=UTF-8');
echo <<<HTML
Error：404
HTML;
exit;
}
if($_POST['go'])
{
$_SESSION['editset']['mei']=floor($_POST['mei']);
$_SESSION['editset']['duan']=$duan=floor($_POST['duan']);
$code=$_POST['code'];
$realpath=realpath($path);
$md5=md5($realpath);
$content=_view($realpath,$duan,$code);
$fn='./data/edit#'.$md5;
$edit=array('path'=>$realpath,'code'=>$code,'content'=>$content);
file_put_contents($fn,serialize($edit));
header('Location: editor.php?path='.$md5);
exit;
}
//header('Content-Type: text/html; charset=UTF-8');
echo <<<HTML
<html>
<head>
<title>文件管理－打开文件</title>
<style type="text/css">.big_board{background-color:#009BCE;color:#FFF;}
.board_title{margin-bottom:1px;border:1px solid #09F;}
</style>
</head><body>
<div class="big_board"><div class="board_title">爱特文管－路径信息</div></div>
HTML;
echo '<a href="index.php?path='._encode($dir=dirname($path)).'">',realpath($dir),'</a>/'.basename($path);
$realpath=realpath($path);
if(is_file($fn='./data/edit#'.($md5=md5($realpath))))
{
echo <<<HTML
<div class="big_board"><div class="board_title">爱特文管－覆盖提示</div></div>
文件已经被打开，<a href="editor.php?path={$md5}">点击进入编辑</a><br/>如果重新在这里打开，那么之前的修改将被覆盖！
HTML;
}
$_SESSION['editset']['duan']<1 && $_SESSION['editset']['duan']=777;
$_SESSION['editset']['mei']<1 && $_SESSION['editset']['mei']=77;
echo <<<HTML
<div class="big_board"><div class="board_title">文件管理－打开选项</div></div>
HTML;
echo <<<HTML
<form action="{$_SERVER['PHP_SELF']}?path={$_GET['path']}" method="post">
文件编码:<select name="code"><option>UTF-8</option><option>GBK</option><option>GB2312</option><option>USC2BE</option><option>USC2LE</option><option>UTF-7</option><option>BASE64</option></select><br/>
分段字数:<input name="duan" value="{$_SESSION['editset']['duan']}" size="3"/><br>
每框字数:<input name="mei" value="{$_SESSION['editset']['mei']}" size="3"/><br/><input name="go" type="submit" value="打开"/><input type="reset" value="重置"/><br/>
<a href="editset.php?path={$_GET['path']}">更多选项</a>
</form>
HTML;
echo <<<HTML
<div class="big_board"><div class="board_title">By：Admin@Lspecial.Com</div></div>
</body>
</html>
HTML;
?>